import difflib
from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep

op = webdriver.ChromeOptions()
op.add_experimental_option('excludeSwitches', ['enable-automation'])
op.add_experimental_option('useAutomationExtension', False)
driver = webdriver.Chrome(options=op)

driver.get(r"http://news.baidu.com/")
Lists = driver.find_elements(By.CSS_SELECTOR,"#localnews-zixun>ul>li>a")
for i in range(0, len(Lists)):
    a = Lists[i]
    a.click()
    content = a.text
    all_handles = driver.window_handles
    driver.switch_to.window(all_handles[1])
    sleep(3)
    title = driver.title
    if len(content) > 10:
        content = content[0:10]
    if len(title) > 10:
        title = title[0:10]
    print(content,title)
    b = difflib.SequenceMatcher(None,content,title).quick_ratio()

    assert b > 0.9
    driver.close()
    driver.switch_to.window(all_handles[0])
    sleep(3)
driver.quit()